// JavaScript Document
function PauseStatus(lgc)
{
	var _this = this;
	LogicStatus.call(_this, lgc)
	
	_this.bg = undefined;
	_this.buttonG = undefined;
	_this.buttonM = undefined;
	//_this.musicButton = undefined;
	
	_this.prepare = function(preStat){
		if(preStat == GAMING)
		{
			sNode = _this.logic.sceneManager.createNode( _this.bg, 4);  
			_this.logic.sceneManager.addNode(sNode);
			 sNode = _this.logic.sceneManager.createNode(_this.buttonG, 1);
			_this.logic.sceneManager.addNode(sNode);
			sNode = _this.logic.sceneManager.createNode(_this.buttonM, 1);
			_this.logic.sceneManager.addNode(sNode);
			//sNode = _this.logic.sceneManager.createNode(_this.musicButton, 1);
//			_this.logic.sceneManager.addNode(sNode);
		}
	}
	
	_this.update = function(){
		// 在这里实现物件的更新, 
	}
	
	_this.mouseClick = function(e){
		//alert("我现在是Pause");
		//_this.logic.statusChange(GAMING);
		var CanvasEle = document.getElementById("myCanvas");
        //alert(distanceCanvas.offsetLeft);
        var mouseX = e.clientX - CanvasEle.offsetLeft;
        var mouseY = e.clientY - CanvasEle.offsetTop;
        //alert(mouseX);
        if(mouseX > _this.buttonM.position.x && mouseX < (_this.buttonM.position.x+_this.buttonM.box.width) && mouseY > _this.buttonM.position.y && mouseY < (_this.buttonM.position.y+_this.buttonM.box.height))
           {
               //alert("我现在是gameOver");
			   marks = 0;   
               _this.clearUp();
               _this.logic.statusChange(MENU);
           }
        if(mouseX > _this.buttonG.position.x && mouseX < (_this.buttonG.position.x+_this.buttonG.box.width) && mouseY > _this.buttonG.position.y && mouseY < (_this.buttonG.position.y+_this.buttonG.box.height))
           {
               //alert("我现在是gameOver");   
               _this.clearUp();
               _this.logic.statusChange(GAMING);
           }
	}
	
	   _this.mouseMove = function(e)
     {
       //鼠标移动
        var CanvasEle = document.getElementById("myCanvas");
        var mouseX = e.clientX - CanvasEle.offsetLeft;
        var mouseY = e.clientY - CanvasEle.offsetTop;
        //alert(mouseX);
        if (mouseX > _this.buttonG.position.x && mouseX < (_this.buttonG.position.x+_this.buttonG.box.width) && mouseY > _this.buttonG.position.y && mouseY < (_this.buttonG.position.y+_this.buttonG.box.height))
        {
           _this.buttonG.changeIn();
         }
        if (mouseX < _this.buttonG.position.x || mouseX > (_this.buttonG.position.x+_this.buttonG.box.width) || mouseY < _this.buttonG.position.y || mouseY > (_this.buttonG.position.y+_this.buttonG.box.height))
         {
            _this.buttonG.changeOut();
         }
         if (mouseX > _this.buttonM.position.x && mouseX < (_this.buttonM.position.x+_this.buttonM.box.width) && mouseY > _this.buttonM.position.y && mouseY < (_this.buttonM.position.y+_this.buttonM.box.height))
        {
           _this.buttonM.changeIn();
         }
        if (mouseX < _this.buttonM.position.x || mouseX > (_this.buttonM.position.x+_this.buttonM.box.width) || mouseY < _this.buttonM.position.y || mouseY > (_this.buttonM.position.y+_this.buttonM.box.height))
         {
            _this.buttonM.changeOut();
         }
     }
     
	_this.keyDown = function(e){
		// 比如我按键之后转换为状态2 : 就这么做:
		//_this.logic.changeStatus(2);
		
	}
	
	// 这个函数用来清理资源
	_this.clearUp = function()
	{
		_this.logic.sceneManager.clearNodeList(); 
	}
	// 这个函数用来查询ready状态.
	
	_this.ready = function()
	{
		return _this.bg.ready && _this.buttonG.ready && _this.buttonM.ready;
	}
	
	var init = function () {
		_this.bg = new Bg(new Vector2(0,0), new Rectangle(480, 768));
        _this.bg.img.src = "./images/pause.png";
             
        _this.buttonG = new ChangeButton(new Vector2(112, 104), new Rectangle(256, 59));
		_this.buttonG.img.src = "./images/BackToGame.png";
		_this.buttonG.src_1 = "./images/BackToGame.png";
        _this.buttonG.src_2 = "./images/BackToGame_h.png"; 
        
        _this.buttonM = new ChangeButton(new Vector2(112, 224), new Rectangle(256, 59));
		_this.buttonM.img.src = "./images/BackToMenu.png";
        _this.buttonM.src_1 = "./images/BackToMenu.png";
        _this.buttonM.src_2 = "./images/BackToMenu_h.png";
		
		//_this.musicButton = new ChangeButton(new Vector2(440, 10), new Rectangle(32, 32));
//		_this.musicButton.img.src = "./images/trumpet_on.png";
//		_this.musicButton.src_1 = "./images/trumpet_on.png";
//		_this.musicButton.src_2 = "./images/trumpet_off.png";
		
	}
	init();
}